

template <typename KEY, typename VALUE>
dictionary<KEY,VALUE>::dictionary(void)
{
}

template <typename KEY, typename VALUE>
dictionary<KEY,VALUE>::~dictionary(void)
{
}

template <typename KEY, typename VALUE>
bool dictionary<KEY,VALUE>::set(KEY k, VALUE v)
{
  if ( _elements.size() > 0 )
  {
    typename std::vector< dictionary_element<KEY,VALUE> >::iterator i, i2;
    i = _elements.begin();
    i2 = _elements.end();

    while ( i != i2 ) 
    {
      dictionary_element<KEY,VALUE> e = *i;
      if ( e.k == k )
      {
        e.v = v;
        return true;
      }
      i++;
    }
  }

  _elements.push_back( dictionary_element<KEY,VALUE>(k,v) );


  return true;
}



template <typename KEY, typename VALUE>
VALUE dictionary<KEY,VALUE>::get(KEY k)
{
  if ( _elements.size() )
  {
    typename std::vector< dictionary_element<KEY,VALUE> >::iterator i, i2;
    i = _elements.begin();
    i2 = _elements.end();

    while ( i != i2 ) 
    {
      dictionary_element<KEY,VALUE> e = *i;
      if ( e.k == k )
      {
        return e.v;
      }
      i++;
    }
  }

  return 0;
}

template <typename KEY, typename VALUE>
bool dictionary<KEY,VALUE>::has(KEY k)
{
  if ( _elements.size() == 0 ) 
    return false;


  typename std::vector< dictionary_element<KEY,VALUE> >::iterator i, i2;
  i = _elements.begin();
  i2 = _elements.end();

  while ( i != i2 ) 
  {
    dictionary_element<KEY,VALUE> e = *i;
    if ( e.k == k )
    {
      return true;
    }
    i++;
  }

  return false;
}

template <typename KEY, typename VALUE>
size_t dictionary<KEY,VALUE>::size()
{
  return _elements.size();
}

template <typename KEY, typename VALUE>
VALUE dictionary<KEY,VALUE>::getByIndex(int index)
{
  if ((index>=0 ) && ( static_cast<int>(size()) > index ))
    return _elements[index].v;

  return 0;
}

template <typename KEY, typename VALUE>
bool dictionary<KEY,VALUE>::remove(KEY k)
{
  bool bDeleted = false;
  
  typename std::vector< dictionary_element<KEY,VALUE> >::iterator i, i2;
  i = _elements.begin();
  i2 = _elements.end();

  while ( i != i2 ) 
  {
    dictionary_element<KEY,VALUE> e = *i;
    if ( e.k == k )
    {
      _elements.erase( i );
    }
    i++;
  }
  


  return bDeleted;
}


template <typename KEY, typename VALUE>
bool dictionary<KEY,VALUE>::clear()
{
  _elements.clear();
  return true;
}



/*
template <typename KEY, typename VALUE>
bool dictionary<KEY,VALUE>::remove(KEY k)
{
}

template <typename KEY, typename VALUE>
bool dictionary<KEY,VALUE>::removeByValue(VALUE v)
{
}


template <typename KEY, typename VALUE>
bool dictionary<KEY,VALUE>::updateKeyForValue(VALUE v, KEY newKey)
{
}
*/